let uu = document.querySelector('.uu')
let span = document.querySelector('span')
let foot = document.querySelector('.footer')
let pin = document.querySelector('.pin')
let xie = document.querySelector('.xie')
function getQueryString() {
    let url = location.href
    console.log(url)
    let reg = /(?<=\?).*/
    let r = url.match(reg)
    console.log(r)
    let rm = r[0]
    console.log(rm)
    let reg2 = /\d/
    let r1 = rm.match(reg2)
    r1 = r1[0]
    r1=Number(r1)
    console.log(r1)
    fetch('http://chst.vip:1234/api/getproductlist?' + rm)
        .then(body => body.json())
        .then(res => {
            console.log(res)
            let reg = res.result
            let domStr = ''
            reg.forEach(item => {
                domStr += `<li productid=${item.productId}>${item.productImg}
            <p>${item.productName}</p>
            <span>${item.productPrice}</span>
            <b>${item.productQuote}${item.productCom}</b>
            </li>`
                uu.innerHTML = domStr
            })

        })
}
getQueryString()
//面包蟹
function mianbao(){
    let title = location.href
    title = decodeURI(title)
    let reg = /(?<=\?).*/
    let tit = title.match(reg)
    let t = tit[0]
    let i = t.split('&')
    let obj = {};
    i.forEach(item => {
        let itemArr = item.split('=');
        obj[itemArr[0]] = itemArr[1]
    })
    console.log(obj['name'])
    let domStr = ''
    domStr = `<b>首页</b>>
                <b class="xie1">全部分类</b>>
                <b>${obj['name']}</b>
                `
    xie.innerHTML = domStr
}
mianbao()
uu.onclick = function (e) {
    if (e.target.localName == 'li') {
        let _this = e.target
        console.log(_this)
        let id = _this.getAttribute('brandtitleid')
        console.log(id);
        // location.href = "./../html/pinpaixiangxiang.html?productid=" + id
        id = Number(id)
    } 
}

uu.onclick = function (e) {
    if (e.target.localName == 'li') {
        let _this = e.target
        let id = _this.getAttribute('productid')
        console.log(id);
        location.href = "./../html/bijiaover.html?productid=" + id
        id = Number(id)
    }
}

xie.onclick = function () {
    location.href = "./../index.html"
}
$('.xie').on('click','.xie1',function(){

    location.href="./../html/bijiaxiang.html"
})



span.onclick = function () {
    location.href = "./../html/bijiaxiang.html"
}
foot.onclick = function () {
    location.href = "./../index.html"
}